<template>
    <!--低保变更中心列表-->
    <div ref="body">
        <Form :label-width="120" inline>

            <Form-item label="属地区划:">
                <area-linkage :areaCode.sync="queryParam.azaa0001"></area-linkage>
            </Form-item>
            <Form-item label="户主姓名:">
                <Input v-model="queryParam.azcp0003" placeholder="请输入户主姓名" style="width:200px"/>
            </Form-item>

            <Form-item label="户主身份证号码:">
                <Input v-model="queryParam.azcp0001" placeholder="请输入户主身份证号码" style="width:200px"/>
            </Form-item>

            <Form-item label="家庭编号:">
                <Input v-model="queryParam.azdf0001" placeholder="请输入家庭编号" style="width:200px"/>
            </Form-item>

            <Form-item label="低保证号:">
                <Input v-model="queryParam.ssca0014" placeholder="请输入低保证号" style="width:200px"/>
            </Form-item>

            <Form-item label="受理编号:">
                <Input v-model="queryParam.ssca0061" placeholder="请输入受理编号" style="width:200px"/>
            </Form-item>

            <Form-item label="批准时间:">
                <DatePicker type="daterange" split-panels v-model="queryParam.ssca0006_time"
                            placeholder="请选择批准时间" style="width: 200px"  :editable="false"></DatePicker>
            </Form-item>
            <Row class="button_row">
                <span style="float: left;">
                  <Button type="primary" @click="todo(200)" icon="ios-brush">动态变更</Button>
                  <Button type="primary" class="button_item_left" @click="todo(300)" icon="md-remove-circle">停保</Button>
                  <Button type="primary" class="button_item_left" @click="todo(500)" icon="ios-undo">区内迁移</Button>
                  <Button type="primary" class="button_item_left" @click="todo(501)" icon="ios-undo">跨区迁移</Button>
                  <Dropdown style="margin-left: 8px" v-if="queryParam.ssca0012=='100'">
                        <Button type="primary" icon="md-shuffle">类别转换<Icon type="ios-arrow-down"></Icon> </Button>
                        <DropdownMenu slot="list">
                         <DropdownItem v-for="item in conversionTypes" :key="item.code" :name="item.code"
                                       @click.native="todo(item.code)">{{item.name}}</DropdownItem>
                   </DropdownMenu>
                 </Dropdown>
                </span>
                <span style="float: right;">
                 <Button type="primary" @click="searchQueryNew">查询</Button>
                 <Button type="primary" class="button_item_left" @click="searchResetNew">重置</Button>
                </span>
            </Row>
        </Form>

        <div class="table_div">
            <vxe-table border
                       resizable
                       row-id="id"
                       :row-key="true"
                       show-overflow="tooltip"
                       align="center"
                       header-align="center"
                       ref="xTree"
                       :loading="Loading"
                       :radio-config="{highlight: true}"
                       @cell-click="selectChange"
                       :data="tableData">
                <vxe-table-column type="radio" width="60" align="center" fixed="left"/>
                <vxe-table-column field="ssca0043" title="属地区划" align="center" width="220" fixed="left"
                                  :formatter="renderAreaName"/>
                <vxe-table-column field="azcp0003" title="户主姓名" align="center" width="100" fixed="left"/>
                <vxe-table-column field="azcp0001" title="户主身份证号码" align="center" width="200" fixed="left"/>
                <vxe-table-column field="azdf0001" title="家庭编号" align="center" width="160"/>
                <vxe-table-column field="ssca0061" title="受理编号" align="center" width="160"/>
                <vxe-table-column field="ssca0014" title="低保证号" align="center" width="140"/>
                <vxe-table-column field="ssca0032" title="数据来源" align="center" width="140" :formatter="renderSsca0032"/>
                <vxe-table-column field="ssca0025" title="分类救助上浮总金额" align="center" width="160"/>
                <vxe-table-column field="fullmoney" title="总金额" align="center" width="140"/>
                <vxe-table-column field="ssca0013" title="致贫原因" align="center" width="140"/>
                <vxe-table-column field="ssca0044" title="家庭基础收入" align="center" width="140"/>
                <vxe-table-column field="ssca0045" title="家庭赡抚养费" align="center" width="140"/>
                <vxe-table-column field="ssca0046" title="家庭财产" align="center" width="140"/>
                <vxe-table-column field="ssca0047" title="家庭支出" align="center" width="140"/>
                <vxe-table-column field="ssca0049" title="家庭月总收入" align="center" width="200"/>
                <vxe-table-column field="ssca0042" title="保障标准" align="center" width="140"/>
                <vxe-table-column field="ssca0052" title="保障人口数" align="center" width="140"/>
                <vxe-table-column field="ssca0003" title="申请时间" align="center" width="140" :formatter="renderTime"/>
                <vxe-table-column field="ssca0033" title="变更申请时间" align="center" width="140" :formatter="renderTime"/>
                <vxe-table-column field="ssca0029" title="审批完成时间" align="center" width="140" :formatter="renderTime"/>
                <vxe-table-column field="bpmstatus" title="数据状态" align="center" width="140"/>
                <vxe-table-column title="操作" align="center" width="140" fixed="right">
                    <template #default="{row}">
                        <Button type="default" @click="searchDetail(row)">查看详情</Button>
                    </template>
                </vxe-table-column>
            </vxe-table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
        <application-modal ref="modal"/>
        <application-change ref="changeModal" @ok="modalFormOk"/>
    </div>
</template>

<script>
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import {getAction, postAction} from '@/api/request'
    import applicationModal from '../db_application_history/applicationModal'
    import applicationChange from '../db_application_change/applicationModal'

    export default {
        name: "search-rescue100100-list",
        components: {applicationModal, applicationChange},
        mixins: [CommonMixin],
        data() {
            return {
                queryParam: {},
                conversionTypes: [],
                // bpm_statusInformation: [
                //     {code: "100", name: "正常"},
                //     {code: "200", name: "动态变更办理中"},
                //     {code: "201", name: "申请人变更办理中"},
                //     {code: "202", name: "死亡停救办理中"},
                //     {code: "203", name: "特殊情况停救办理中"},
                //     {code: "204", name: "调标变更办理中"},
                //     {code: "212", name: "转换城市最低生活保障办理中"},
                //     {code: "213", name: "转换城市单人保障办理中"},
                //     {code: "214", name: "转换城市因病致贫保障办理中"},
                //     {code: "215", name: "转换农村最低生活保障办理中"},
                //     {code: "216", name: "转换农村单人保障办理中"},
                //     {code: "217", name: "转换农村因病致贫保障办理中"},
                //     {code: "218", name: "转换农村建档立卡保障办理中"},
                //     {code: "300", name: "保障停救办理中"},
                //     {code: "300", name: "停保办理中"},
                //     {code: "400", name: "复审办理中"},
                //     {code: "500", name: "区内迁移办理中"},
                //     {code: "501", name: "跨区迁移办理中"},
                // ],
                Loading: true,
                show: false,
                selectRow: null,
                url: {
                    list: "/api/ac/subsistence/ss12001Service/searchRescue",
                },
                dictList: [],
                ssca0012: "",
                ssca0002: "",
            }
        },
        methods: {
            selectChange({row}) {
                this.$refs.xTree.setRadioRow(row);
                this.selectRow = row;
            },
            renderSsca0032(h) {
                if (h.cellValue == '200') {
                    return '历史导入数据';
                } else if (h.cellValue == '300') {
                    return '推送数据';
                } else if (h.cellValue == '100') {
                    return '填报数据';
                }
            },
            clearRadioRowEevnt() {
                this.selectRow = null
                this.$refs.xTree.clearRadioRow()
            },
            searchQueryNew() {
                var time = this.queryParam.ssca0006_time;
                if (time) {
                    if (time[0]) {
                        this.queryParam.ssca0006_begin = this.DateFormat(time[0], 'YYYY-MM-DD') + " 00:00:00";
                    } else {
                        this.queryParam.ssca0006_begin = "";
                    }
                    if (time[1]) {
                        this.queryParam.ssca0006_end = this.DateFormat(time[1], 'YYYY-MM-DD') + " 23:59:59";
                    } else {
                        this.queryParam.ssca0006_end = "";
                    }
                }
                this.clearRadioRowEevnt();
                this.loadData(1);
            },
            searchResetNew() {
                this.queryParam = {};
                this.queryParam.isMember = "0";
                this.queryParam.ssca0012 = this.ssca0012;
                this.queryParam.ssca0002 = this.ssca0002;
                this.clearRadioRowEevnt();
                this.loadData(1);
            },
            loadData(arg) {
                if (arg == 1) {
                    this.pageNo = 1;
                }
                let that = this;
                that.Loading = true;
                let param = Object.assign({}, this.queryParam);
                let url = this.url.list;
                param.pageNo = this.pageNo;
                param.pageSize = this.pageSize;
                postAction(url, param).then((res) => {
                    if (res.data.errcode != 0) {
                        this.$Message.error(res.data.errmsg);
                    } else {
                        that.tableData = res.data.data.pageList.results;
                        that.dataCount = res.data.data.pageList.totalRecord;
                    }
                }).finally(() => {
                    that.Loading = false;
                })
            }
            ,
            todo(type) {
                var row = this.selectRow;
                if (this.selectRow) {
                    row.ssca0002 = this.queryParam.ssca0002;
                    row.ssca0012 = this.ssca0012;
                    if (row.bpmStatusCode == "100") {
                        if (row.ssca0011 == null || row.ssca0011 == "") {
                            message = "请先完善银行账户信息！";
                            this.$Message.error(message);
                        } else if(row.warnlock=='lock'){
                            message = "存在未完成处置的预警数据，请先进行预警处置！";
                            this.$Message.error(message);
                        } else{
                            row.ssca0016 = type;
                            var width = this.$refs.body.clientWidth;
                            this.$refs.changeModal.edit(row);
                            this.$refs.changeModal.width = width + 40;
                            this.$refs.changeModal.key = this.uuid();
                        }
                    } else {
                        var message = '当前数据' + row.bpmstatus + "！";
                        this.$Message.error(message);
                    }
                } else {
                    this.$Message.error("请选择需要动态变更的数据!");
                }
            }
            ,
            searchDetail(row) {
                row.processinstid = row.ywgl004;
                var width = this.$refs.body.clientWidth;
                this.$refs.modal.edit(row);
                this.$refs.modal.width = width + 40;
                this.$refs.modal.key = this.uuid();
            }
            ,
            edit(queryParam, conversionTypes) {
                this.ssca0012 = queryParam.ssca0012;
                this.ssca0002 = queryParam.ssca0002;
                this.queryParam = queryParam;
                this.conversionTypes = conversionTypes;
                this.findAreaList();
            }
            ,
            modalFormOk() {
                this.selectRow = null;
                // 新增/修改 成功时，重载列表
                this.loadData();
            },
        },

    }
</script>

<style scoped>


    /deep/ .ivu-upload-list {
        display: none;
    }

    /deep/ .ivu-table-cell {
        padding-right: 0px;
        padding-left: 0px;
    }

    #statistics {
        height: 50px;
        line-height: 50px;
        width: 100%;
        color: red;
        font-size: 16px;
    }

    #statistics span {
        padding-left: 10px;
        padding-right: 10px;
    }

</style>
